package com.struts;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.dao.Test1;
import com.dao.FwxxBiz;
import com.dao.impl.FwxxBizImpl;
import com.dao.impl.TestImpl;
import com.entity.Fwxx;
import com.entity.User;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class FwxxAction extends ActionSupport{
	private static final long serialVersionUID = -8249174277536482098L;
	private DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	private FwxxBiz biz = new FwxxBizImpl();
	private Fwxx fw = new Fwxx();
	private int uid ;
	private String confirm =null ;
	private String qx=null ;
	private String jdname = null ;
	private String fwname= null ;
	private List<Fwxx> fwlist=null;
	/*private String title="";
      private int zj=0;
      private int qxid;
  	  private int jdid;
	    private int lxid;
	    private int shi=0;
	    private int ting=0;
	    private String fwxx="";
	    private String date=null;
	    private String telephone="";
	    private String lxr="";*/
   
	public String post() throws Exception {
		// TODO Auto-generated method stub
		
		User user = (User)ActionContext.getContext().getSession().get("USER") ;
		
		if(user==null){
			return "nologin";
		}
		fw.setUid(user.getUid()) ;
		
		fw.setDate(df.format(new Date()));
		System.out.println(confirm);
		if(confirm==null||"yes".equals(confirm)){
			Test1 dao = new TestImpl();
			if(fw.getLxid()!=0){
				fw.setFwname(dao.getFwName(fw.getLxid())) ;
			}
			if(fw.getJdid()!=0){
				fw.setJdname(dao.getJdName(fw.getJdid())) ;
				int qxid = dao.getQxid(fw.getJdid()) ;
				if(qxid!=0){
					fw.setJdname(dao.getQxName(qxid)) ;
				}
			}
			return "confirm" ;
		}
		
		biz.PostFwxx(fw) ;
		return SUCCESS;
	}
    public String toList(){
    	fwlist=biz.getFwxxList(fw.getTitle());
		return "list";
    }
	
	public Fwxx getFw() {
		return fw;
	}


	public void setFw(Fwxx fw) {
		this.fw = fw;
	}


	public String getQx() {
		return qx;
	}


	public void setQx(String qx) {
		this.qx = qx;
	}


	public String getJdname() {
		return jdname;
	}


	public void setJdname(String jdname) {
		this.jdname = jdname;
	}


	public String getFwname() {
		return fwname;
	}


	public void setFwname(String fwname) {
		this.fwname = fwname;
	}


	
	public int getUid() {
		return uid;
	}


	public void setUid(int uid) {
		this.uid = uid;
	}


	public String getConfirm() {
		return confirm;
	}


	public void setConfirm(String confirm) {
		this.confirm = confirm;
	}


	public List<Fwxx> getFwlist() {
		return fwlist;
	}


	public void setFwlist(List<Fwxx> fwlist) {
		this.fwlist = fwlist;
	}
}
